package map.android.baidu.carpool.hybrid;

import android.annotation.SuppressLint;
import android.content.Context;
import android.os.Build;
import android.util.AttributeSet;
import android.view.View;
import android.webkit.WebView;

public class HBWebView extends WebView {

	public HBWebView(Context context) {
		super(context);
		init();
	}

	public HBWebView(Context context, AttributeSet attrs, int defStyle) {
		super(context, attrs, defStyle);
		init();
	}

	public HBWebView(Context context, AttributeSet attrs) {
		super(context, attrs);
		init();
	}

	@SuppressLint("SetJavaScriptEnabled")
	private void init() {
		getSettings().setJavaScriptEnabled(true);
		getSettings().setAppCacheEnabled(true);
		setScrollBarStyle(View.SCROLLBARS_INSIDE_OVERLAY);
		getSettings().setGeolocationEnabled(true);

		// 开启HTML5离线存储
		getSettings().setDomStorageEnabled(true);
		getSettings().setAllowFileAccess(true);

		// 开启HTML5 Web SQL Database API
		getSettings().setDatabaseEnabled(true);
		removeJSInterface(this);
	}

	@SuppressLint("NewApi")
	private void removeJSInterface(WebView webView) {
		if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
			webView.removeJavascriptInterface("searchBoxJavaBridge_");
		}
	}

	@Override
	public boolean performLongClick() {
		return true;
	}
}
